package cn.cena.feign.client;

import cn.cena.domain.Login;
import cn.cena.dto.RelationLogin2MealDto;
import cn.cena.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
class LoginFeignClientFallbackFactoy implements FallbackFactory<LoginFeignClient> {

    @Override
    public LoginFeignClient create(Throwable throwable) {
        return new LoginFeignClient() {
            @Override
            public AjaxResult save(Login login) {
                log.error("注册失败:{}",throwable.getMessage());
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("注册失败");
            }

            @Override
            public AjaxResult saveLoginAndMeal(RelationLogin2MealDto login2MealDto) {
                log.error("注册失败:{}",throwable.getMessage());
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("注册失败");
            }
        };
    }
}
